﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;
using Core.DS;

namespace Web.Controllers
{
    public partial class datastructController : JsonController
    {
        [NeedLogon]
        public ActionResult submitCd(HttpPostedFileBase userfile, string subjects)
        {
            IsFileUpload = true;
            CheckNull(userfile);
            var filename = userfile.FileName;
            var ext = System.IO.Path.GetExtension(filename).ToLower();
            return Json(CourseDesign.submitCd(Certify.username, subjects, userfile, ext));
        }

        public ActionResult showCourseDesignList(int start, int limit)
        {
            return Json(CourseDesign.showCourseDesignList(start, limit));
        }

        [OnlyGod]
        [OnlyTeacherUp]
        public ActionResult deleteCourseDesign(int id)
        {
            return Json(CourseDesign.deleteCd(id));
        }

        [OnlyGod]
        [OnlyTeacherUp]
        public ActionResult addOrEditCourseDesign(int? id, string title, string description)
        {
            return Json(CourseDesign.addOrEditCourseDesign(id, title, description));
        }

        [OnlyGod]
        [OnlyTeacherUp]
        public ActionResult submitCdPoint(int point)
        {
            return Json(CourseDesign.submitCdPoint(point, Certify.username));
        }

        [OnlyGod]
        [OnlyTeacherUp]
        public ActionResult packageCd(int cid, string sid,bool isCls)
        {
            return Json(CourseDesign.package(cid, sid, isCls));
        }

        [OnlyGod]
        [OnlyTeacherUp]
        public ActionResult showCDStatistics(int cid)
        {
            return Json(CourseDesign.showCDStatistics(cid));
        }
    }
}